//
//  WNAccountVC.swift
//  WalkNovel
//
//  Created by Kevin on 2023/8/31.
//

import UIKit
import KeychainAccess
import AuthenticationServices

class WNAccountVC: WNBaseVC {
    
    lazy var accTabView: WNTableView = {
        let tab = WNTableView()
        tab.register(SettingCell.self, forCellReuseIdentifier: SettingCell.identifier)
        tab.backgroundColor = .init(named: "white_F7F7F7")
        tab.delegate = self
        tab.dataSource = self
        tab.rowHeight = 60
        tab.isScrollEnabled = false
        return tab
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func viewConfig() {
        view.addSubview(accTabView)
        accTabView.snp.makeConstraints { make in
            make.top.equalTo(NaviTotalHeight)
            make.left.bottom.right.equalTo(0)
        }
    }
    
    var appleBindType = 0
    
    override func dataConfig() {
        pageName = "帳戶與安全"
        navView.titleName = "帳戶與安全"
    }
}

extension WNAccountVC: UITableViewDelegate, UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: SettingCell.identifier, for: indexPath) as! SettingCell
        cell.accountType = indexPath.item
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.item {
        case 0:
            wn_pushWebVC(WNConfigure.WNURL.wn_Agreement, "服務協議")
        case 1:
            wn_pushWebVC(WNConfigure.WNURL.wn_Privacy, "隱私政策")
        case 2:
            navigationController?.pushViewController(WNCancelVC(), animated: true)
        default: break
        }
    }
}
